#ifndef AVERAGEVECTOR_H
#define AVERAGEVECTOR_H

#include "geometry/vector3d.h"

Vector3D *AverageVector(QList<Vector3D*> *vectors) {
    int vectorsCount = vectors->count();
    double deltaX = 0, deltaY = 0, deltaZ = 0;

    for (int v = 0; v < vectors->count(); v++) {
        Vector3D *vector = vectors->at(v);
        deltaX += vector->getDeltaX();
        deltaY += vector->getDeltaY();
        deltaZ += vector->getDeltaZ();
    }

    deltaX /= vectorsCount; deltaY /= vectorsCount;
    deltaZ /= vectorsCount;

    return new Vector3D(deltaX, deltaY, deltaZ);
}

#endif // AVERAGEVECTOR_H
